package org.example.everyday;

public class Lc2028 {

    public int[] missingRolls(int[] rolls, int mean, int n) {
        int m = rolls.length;
        int sum = mean * (n + m);
        int missingSum = sum;
        for (int roll : rolls) {
            missingSum -= roll;
        }
        if (missingSum < n || missingSum > 6 * n) {
            return new int[0];
        }
        int quotient = missingSum / n, remainder = missingSum % n;
        int[] missing = new int[n];
        for (int i = 0; i < n; i++) {
            missing[i] = quotient + (i < remainder ? 1 : 0);
        }
        return missing;

    }

    public static void main(String[] args) {
        Lc2028 lc2028  = new Lc2028();
        int[] rolls = {1,4,6};
        int mean = 3, n = 4;
        int[] result = lc2028.missingRolls(rolls,mean,n);
        for (int i = 0; i < result.length; i++) {
            System.out.println(result[i]);
        }
    }
}
